package com.bkgy.controller.tcmReport.controller;

import com.bkgy.controller.tcmReport.service.IRepTcmOutputInfService;
import com.bkgy.controller.tpdol3data.entity.dto.OutputReq;
import com.bkgy.sys.common.entity.ResultData;
import com.bkgy.util.DateUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

@Tag(name = "酸轧报表总览")
@Controller
@RequestMapping("/tcmReport")
@RequiredArgsConstructor
public class RepTcmOutputInfController {
    private final IRepTcmOutputInfService service;

    @Operation(summary = "酸轧班组报表》影响产量列表", description = "重焊、开卷异常影响产量列表")
    @PostMapping("/infOutput")
    @ResponseBody
    public ResultData infOutput(@RequestBody OutputReq req) {
        String date = req.getStartDate();
        //默认查询上一天时间
        if (StringUtils.isEmpty(date)) {
            date = DateUtil.getDateToString(DateUtil.getBeforDate(), "yyyyMMdd");
        } else {
            Date d = DateUtil.getStringToDate("yyyy-MM-dd", date);
            date = DateUtil.getDateToString(d, "yyyyMMdd");
        }
        return service.infOutput(date);
    }
}
